package com.lin.Service.Impl;

import com.lin.Service.UserService;
import com.lin.UserDao;
import com.lin.User;
import lombok.Setter;
import org.springframework.beans.factory.InitializingBean;

import java.util.List;

@Setter
public class UserServiceImpl2 implements UserService, InitializingBean {
    private UserDao userDao;
    private List<String> stringList;
    private List<UserDao> userList;


    public UserServiceImpl2(String name){
        System.out.println("有参构造器执行");
    }

    public UserServiceImpl2(){
        System.out.println("无参构造器执行");
    }

    // setter注入
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
        System.out.println("beanFactory调用该方法获取UserDao: " + userDao);
    }

    @Override
    public User test() {
        this.stringList.forEach(System.out::println);
        this.userList.forEach(System.out::println);
        return userDao.test();
    }

    public void init() {
        System.out.println("初始化方法");
    }

    public void destroy() {
        System.out.println("销毁方法");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("afterPropertiesSet执行...");
    }
}
